// const MongoClient = require('mongodb').MongoClient;
const {MongoClient, ObjectID} = require('mongodb');


MongoClient.connect('mongodb://localhost:27017/TodaApp', (err, db) => {
    if (err) {
        return console.log('Unable to connect the mongodb server')
    }

    console.log('Connected to MongDB server');

    // db.db('TodoApp').collection('Todos').findOneAndUpdate({
    //         _id: new ObjectID('5a38bf521a71aad3e03b0957')
    //     }, {
    //         $set: {completed: true}
    //     }, {
    //         returnOriginal: false
    //     }
    // ).then((res) => {
    //     console.log(res);
    // })

    db.db('TodoApp').collection('Users').findOneAndUpdate(
        {_id: new ObjectID('5a3894e506c49fc576da7d8b')},
        {$set:{name: 'Tony'},$inc:{age: 1}},
        {returnOriginal:false}
        ).then((res) => {
            console.log(res)
    })


    // db.close();

})

